<template>
  <div class="sku-edit">
    <div class="navbar flex-x-bet-y-center">
      <i class="el-icon-back back" @click="back()"></i>
      <div>增加规格</div>
      <div class="empty"></div>
    </div>
    <SkuList v-model="skuList" @submit="submit"></SkuList>
  </div>
</template>

<script>
import SkuList from "@/components/skuList.vue";
export default {
  name: "addSkuList",
  components: {
    SkuList,
  },
  data() {
    return {
      skuList: [],
    };
  },
  created() {
    this.skuList = JSON.parse(sessionStorage.getItem("formData")).form.hgProductSkus;
  },
  methods: {
    back(){
      sessionStorage.setItem('isSkuBack', 1)
      this.$router.back();
    },
    submit() {
      const formData = JSON.parse(sessionStorage.getItem("formData"));
      formData.form.hgProductSkus = this.skuList;
      sessionStorage.setItem("formData", JSON.stringify(formData));
      sessionStorage.setItem('isSkuBack', 1)
      this.$router.back();
    },
  },
};
</script>

<style lang="scss" scoped>
.sku-edit {
  width: 100%;
  min-height: 717px;
  margin: 0 auto 30px;
  background: #fff;
}

.navbar {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 26px;
  color: #333333;
  padding: 20px 30px;
  text-align: center;

  .back {
    cursor: pointer;
  }
}
</style>
